
<!DOCTYPE html>
<html>
<head>
<!--	<script type="text/javascript">-->
<!--		function getlist(e) {-->
<!--			$.ajax({-->
<!--				url : "/o2o/shopadmin/getshoplist",-->
<!--				type : "get",-->
<!--				dataType : "json",-->
<!--				beforeSend : function(request){-->
<!--					request.setRequestHeader("token",localStorage.getItem("token"));-->
<!--				},-->
<!--				success : function(data) {-->
<!--					if (data.success) {-->
<!--						handleList(data.shopList);-->
<!--						handleUser(data.user);-->
<!--					}-->
<!--				}-->
<!--			});-->
<!--		}-->
<!--	</script>-->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>商店列表</title>
<meta name="viewport" content="initial-scale=1, maximum-scale=1">
<link rel="shortcut icon" href="/favicon.ico">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="stylesheet"
	href="../resources/css/common/sm.min.css">
<link rel="stylesheet"
	href="../resources/css/common/sm-extend.min.css">
<link rel="stylesheet" href="../resources/css/shop/shoplist.css">

	<script type='text/javascript'
			src='../resources/js/common/zepto.min.js' charset='utf-8'></script>
	<script type='text/javascript'
			src='../resources/js/common/sm.min.js' charset='utf-8'></script>
	<script type='text/javascript'
			src='../resources/js/common/sm-extend.min.js' charset='utf-8'></script>
	<script type='text/javascript' src='../resources/js/shop/shoplist.js'
			charset='utf-8'></script>
	<script type='text/javascript' src='../resources/js/local/logout.js'
			charset='utf-8'></script>
	<script type="text/javascript">

		function handleUser(data) {
			$('#user-name').text(data.name);
		}

		function handleList(data) {
			var html = '';
			data.map(function(item, index) {
				html += '<div class="row row-shop"><div class="col-40">'
						+ item.shopName + '</div><div class="col-40">'
						+ shopStatus(item.enableStatus)
						+ '</div><div class="col-20">'
						+ goShop(item.enableStatus, item.shopId) + '</div></div>';

			});
			$('.shop-wrap').html(html);
		}

		function shopStatus(status) {
			if (status == 0) {
				return '审核中';
			} else if (status == -1) {
				return '店铺非法';
			} else if (status == 1) {
				return '审核通过';
			}
		}

		function goShop(status, id) {
			if (status == 1) {
				return '<a href="/o2o/shopadmin/shopmanagement?shopId=' + id
						+ '">进入</a>';
			} else {
				return '';
			}
		}

		function getlist() {
			$.ajax({
				url : "/o2o/shopadmin/getshoplist",
				type : "get",
				dataType : "json",
				beforeSend : function(request){
					request.setRequestHeader("token",localStorage.getItem("token"));
				},
				success : function(data) {
					if (data.success) {
						handleList(data.shopList);
						handleUser(data.user);
					}
				}
			});
		}


		window.onload = function (){
			getlist()
		}
	</script>
</head>
<body>
	<header class="bar bar-nav">
		<h1 class="title">商店列表</h1>
	</header>
	<div class="content">
		<div class="content-block">
			<p>
				你好,<span id="user-name"></span><a class="pull-right"
					href="/o2o/shopadmin/shopoperation">增加店铺</a>
			</p>
			<div class="row row-shop">
				<div class="col-40">商店名称</div>
				<div class="col-40">状态</div>
				<div class="col-20">操作</div>
			</div>
			<div class="shop-wrap"></div>
		</div>
		<div class="content-block">
			<div class="row">
				<div class="col-33">
					<a href="/o2o/local/accountbind?usertype=2"
						class="button button-big button-fill button-success">帐号绑定</a>
				</div>
				<div class="col-33">
					<a href="#" id="log-out" usertype="2"
						class="button button-big button-fill button-danger">退出系统</a>
				</div>
				<div class="col-33">
					<a href="/o2o/local/changepsw?usertype=2"
						class="button button-big button-fill button-success"
						id="bindOrChange">修改密码</a>
				</div>
			</div>
		</div>
	</div>






</body>
</html>
